<style lang="scss" scoped>
</style>

<template>
  <div>
    <van-nav-bar
      title="设置昵称"
      left-text=""
      right-text="完成"
      left-arrow
      @click-left="router.go(-1)"
      @click-right="router.push('/bank')"
    />
    <el-Input clearable v-model="nickname" placeholder="请输入昵称" @change="handleChange"></el-Input>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

// 路由跳转
const router = useRouter()

// 修改昵称
const nickname = ref('')

// 修改昵称
const user = ref(JSON.parse(localStorage.getItem('userInfo')) || '')
nickname.value = user.value.username

// 修改昵称
const handleChange = () => {
  user.value.username = nickname.value
  localStorage.setItem('userInfo', JSON.stringify(user.value))
}
</script>